<?php
class database
{
	public $c = null;
	
	function __construct($hostname = "localhost", $username = "root", $password = "", $database = "failbook") {
		$this->c = mysql_connect($hostname, $username, $password);
		if(!$this->c) {
			die('Impossibile connettersi: ' . mysql_error());
		} else {
			mysql_select_db($database, $this->c);
		}
	}
	function select($query) {
		return mysql_query($query);
	}
	function exist($query) {
		if(mysql_num_rows(mysql_query($query)) != 0) {
			return true;
		} else {
			return false;
		}
	}
	function insert($query) {
		mysql_query($query);
		return mysql_insert_id();
	}
	function update($query) {
		if(mysql_query($query)) {
			return true;
		} else {
			return false;
		}
	} }
?>